﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StudentResult
{

    public partial class Form1 : Form
    {
        StudentInfo stuinfo;
        public Form1()
        {
            InitializeComponent();
            stuinfo = new StudentInfo();
        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox7_Leave(object sender, EventArgs e)
        {
            SetValues();
            stuinfo.ResTotal();
            lblTotal.Text = stuinfo.Total.ToString();
         }

        private void SetValues()
        {
            stuinfo.Name = txtName.Text;
            stuinfo.Rollno = txtRollno.Text;
            stuinfo.Sub1 = ConvertToIneger(txtSub1.Text);
            stuinfo.Sub2 = ConvertToIneger(txtSub2.Text);
            stuinfo.Sub3 = ConvertToIneger(txtsub3.Text);
            stuinfo.Sub4 = ConvertToIneger(txtSub4.Text);
            stuinfo.Sub5 = ConvertToIneger(txtSub5.Text);

            
        }
        private int ConvertToIneger(string str)
        {
            if (str == "")
            {
                return 0;
            }
            return Convert.ToInt32(str);
        }

        private void txtSub2_Leave(object sender, EventArgs e)
        {
            SetValues();
            stuinfo.ResTotal();
            lblTotal.Text = stuinfo.Total.ToString();
        }
    }
}
